import java.util.ArrayList;
import java.util.List;

//leetcode 78 子集
public class Subsets {
    private List<List<Integer>> list;
    private List<Integer> path;
    public List<List<Integer>> subsets(int[] nums) {
        list = new ArrayList<>();
        path = new ArrayList<>();
        dfs(nums, 0);
        return list;
    }

    private void dfs(int[] nums, int pos) {
        list.add(new ArrayList<>(path));
        for (int i = pos; i < nums.length; i++) {
            path.add(nums[i]);
            dfs(nums, i + 1);
            path.remove(path.size() - 1);
        }
    }
}
